<template>
  <div class="login-phone">
    <el-form label-width="80px" :rules="rules" :model="inputInfo">
      <el-form-item label="手机号:" prop="phone">
        <el-input v-model="inputInfo.phone" />
      </el-form-item>
      <el-form-item label="验证码:" prop="password">
        <el-input v-model="inputInfo.password" type="password" />
        <el-button type="primary" class="codeBtn">验证码</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive } from 'vue'

export default defineComponent({
  name: 'login-phone',
  setup() {
    const inputInfo = reactive({
      phone: '',
      password: ''
    })
    let rules = {
      phone: [
        {
          required: true,
          message: '帐号不能为空',
          trigger: 'blur'
        },
        {
          pattern: /^1[3-9]\d{9}$/,
          message: '必须为正常手机号',
          trigger: 'blur'
        }
      ],
      password: [
        {
          required: true,
          message: '验证码不能为空',
          trigger: 'blur'
        }
      ]
    }
    return {
      inputInfo,
      rules
    }
  }
})
</script>

<style lang="less" scoped>
::v-deep .el-form-item__content {
  flex-wrap: nowrap;
}
.codeBtn {
  margin-left: 10px;
}
</style>
